/* parser */

#ifndef BFPARSER_H
#define BFPARSER_H

#include "blex.h"
#include "bconf.h"

#define MAXCODESIZE 500000

typedef struct{
	Token_t t;
	int extra;
}opcode;

typedef int Mem_t;

typedef struct{
	int codelen;	/* lenth of code */
	opcode* code;	/* code */
	Tokendata t;	/* lookahead */
	int error;		/* number of errors */
	int loop_p;		/* position of the last nest loop */
}Proto;

void initProto(Proto* p);
Proto* parse(Proto* p, LState* l);
//Proto* testProto(Proto* p, LState* l);

#define save(p, l)	((p)->t = lex(l))

#endif	/* BFPARSER_H */
